<include file="public@header"/>
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('school/index')}">学校列表</a></li>
        <li class="active"><a href="{:url('school/add')}">添加学校</a></li>
    </ul>
    <form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('school/addPost')}">
        <div class="form-group">
            <label for="input-name" class="col-sm-2 control-label">学校名称<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-name" name="name">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">所属省份<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select name="province" class="form-control" id="input-province">
                    <option value="">|--请选择省份--|</option>
                    <foreach name="province" item="vo">
                        <option value="{$vo.areaId}">{$vo.areaName}</option>
                    </foreach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">所属城市<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select name="city" id="input-city" class="form-control">
                    <option value="">|--请选择城市--|</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">所属县区<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10" >
                <select name="area" id="input-area" class="form-control">
                    <option value="">|--请选择县区--|</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label for="input-address" class="col-sm-2 control-label">详细地址<span class="form-required">*</span></label>
            <div class="col-md-6 col-sm-10">
                <input type="text" class="form-control" id="input-address" name="address">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary js-ajax-submit">{:lang('ADD')}</button>
                <a class="btn btn-default" href="{:url('school/index')}">{:lang('BACK')}</a>
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $(function () {
        $('#input-province').change('click',function () {
            var areaId=$(this).val();
            $.ajax({
                url:"{:url('school/getCity')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    console.log(res);
                    $('#input-city').html(res);
                }
            })
        })
    });
    $(function () {
        $('#input-city').on('change',function () {
            var areaId=$(this).val();
            $.ajax({
                url:"{:url('school/getArea')}",
                type:"POST",
                data:{areaId:areaId},
                success:function (res) {
                    console.log(res);
                    $('#input-area').html(res);
                }
            })
        })
    })
</script>
</body>
</html>